package com.ruoyi.web.controller.ltd_web;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ltd_web.domain.LtdStaffActivity;
import com.ruoyi.ltd_web.service.ILtdStaffActivityService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公司员工活动信息Controller
 *
 * @author ruoyi
 * @date 2024-12-17
 */
@RestController
@RequestMapping("/system/activity")
public class LtdStaffActivityController extends BaseController
{
    @Autowired
    private ILtdStaffActivityService ltdStaffActivityService;

    /**
     * 查询公司员工活动信息列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(LtdStaffActivity ltdStaffActivity)
    {
        startPage();
        List<LtdStaffActivity> list = ltdStaffActivityService.selectLtdStaffActivityList(ltdStaffActivity);
        return getDataTable(list);
    }

    /**
     * 导出公司员工活动信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:activity:export')")
    @Log(title = "公司员工活动信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LtdStaffActivity ltdStaffActivity)
    {
        List<LtdStaffActivity> list = ltdStaffActivityService.selectLtdStaffActivityList(ltdStaffActivity);
        ExcelUtil<LtdStaffActivity> util = new ExcelUtil<LtdStaffActivity>(LtdStaffActivity.class);
        util.exportExcel(response, list, "公司员工活动信息数据");
    }

    /**
     * 获取公司员工活动信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:activity:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ltdStaffActivityService.selectLtdStaffActivityById(id));
    }

    /**
     * 新增公司员工活动信息
     */
    @PreAuthorize("@ss.hasPermi('system:activity:add')")
    @Log(title = "公司员工活动信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LtdStaffActivity ltdStaffActivity)
    {
        return toAjax(ltdStaffActivityService.insertLtdStaffActivity(ltdStaffActivity));
    }

    /**
     * 修改公司员工活动信息
     */
    @PreAuthorize("@ss.hasPermi('system:activity:edit')")
    @Log(title = "公司员工活动信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LtdStaffActivity ltdStaffActivity)
    {
        return toAjax(ltdStaffActivityService.updateLtdStaffActivity(ltdStaffActivity));
    }

    /**
     * 删除公司员工活动信息
     */
    @PreAuthorize("@ss.hasPermi('system:activity:remove')")
    @Log(title = "公司员工活动信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ltdStaffActivityService.deleteLtdStaffActivityByIds(ids));
    }

    /**
     * 查询公司员工活动信息列表
     */
    @Anonymous
    @GetMapping("/listByStatus")
    public AjaxResult listByStatus(LtdStaffActivity ltdStaffActivity)
    {
        return AjaxResult.success(ltdStaffActivityService.selectLtdStaffActivityList(ltdStaffActivity));
    }
}
